package com.aaa.dem1103.d02;

/**
 * @Author: whj
 * @Version 1.0
 * @Date: 2022/11/3  9:54
 */
public class Test2 {
    public static void main(String[] args) {
        //无需参数类型
        Operator o = (arr) -> {
            int sum = 0;
            for (int b : arr) {
                sum += b;
            }
            return sum;
        };
        fun(o);
    }

    public static void fun(Operator operator) {
        int sum[] = {11, 12, 13, 14};
        int sum1 = operator.getSum(sum);
        System.out.println("数组中元素的和:" + sum1);
    }
}

interface Operator {
    //求数组中元素的和
    public int getSum(int[] arr);
}